home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-03-24 | 1.8 KB | 50 lines | [TEXT/MPS ] |
- What's in the Scrap?????
-
- This question comes in to DTS every so often, so here's the answer.
-
- First a NOTE: This only applies to the in-memory scrap! This is NOT
- the ScrapBook format, that is covered in a seperate tech note entitled
- Scrapbook File Format.
-
- The scrap is simply a handle containing chunks of data. The basic format
- is
- OSType OSType of this scrap data
- long Size of this scrap data
- {variable} The actual data
-
- So, you can walk through the scrap by getting the scrap handle (with InfoScrap)
- and advancing through the records. That's what the function
- ParseScrap()
- in this small sample does, please steal as needed.
-
- To see multiple formats in the Scrap, launch Simple and switch to the Finder.
- Do a GetInfo on a Finder icon, select the icon in the Info Window, and do a
- 'Copy'. Now switch back to Simple and you'll see that the Finder has
- put 7 different types in the Scrap.
-
- Some interesting notes:
-
- • You can add multiple formats to the current scrap (like the Finder does for icons)
- just by calling PutScrap repeatedly. PutScrap appends whatever data you pass in
- to the existing scrap handle with a simple PtrToHand(...) call.
- This means, by the way, that there is NO checking for the existence of that
- type in the scrap already!
- If you do a
- PutScrap(textLen,'TEXT', textPtr);
- PutScrap(textLen,'TEXT', textPtr);
-
- You will now have two TEXT's in the scrap handle.
-
- Of course, only the first one is accessable with GetScrap, because the Scrap Manager will
- stop when it finds the first.
-
- This happens because the Scrap Manager _assumes_ that you have called ZeroScrap
- before you call PutScrap.
-
- • Odd data. If the data you add to the scrap has an odd length (like, 13 text
- characters) then the Scrap Manager adds 1 to make the handle even. You'll notice
- I'm checking for and correcting for that in ParseScrap.
-
-
- C.K. Haun
- DTS